package com.cx.mall.demo.controller;

import com.cx.mall.common.utils.ResponseVO;
import com.cx.mall.demo.model.UserReceiveAddress;
import com.cx.mall.demo.service.IDemoUserReceiveAddressSrevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping()
public class DemoUserReceiveAddressController {
    @Autowired
    IDemoUserReceiveAddressSrevice userReceiveAddressSrevice;

    @GetMapping("/userReceiveAddress/listAll")
    public ResponseVO queryUserReceiveAddress() {
        List<UserReceiveAddress> list = userReceiveAddressSrevice.list();
        return ResponseVO.success(list);
    }

    @GetMapping("/userReceiveAddress/getAddressByUserId")
    public ResponseVO getAddressById(long userId){
        UserReceiveAddress userReceiveAddress = userReceiveAddressSrevice.getById(userId);
        return ResponseVO.success(userReceiveAddress);
    }

    @GetMapping("/userReceiveAddress/getAddressByCity")
    public ResponseVO getAddressByCity(String city){
        List<UserReceiveAddress> list = userReceiveAddressSrevice.selectByCity(city);
        return ResponseVO.success(list);
    }
}
